package com.sinoglobal.ningxia.activity.mico;

import android.content.Intent;
import android.os.Bundle;

import com.sinoglobal.networkconnections.ResultCallback;
import com.sinoglobal.ningxia.R;
import com.sinoglobal.ningxia.activity.base.BaseActivity;
import com.sinoglobal.ningxia.beans.programInfoVo;
import com.sinoglobal.ningxia.downdata.imp.RemoteImpl;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

import static com.sinoglobal.ningxia.service.VersionService.url;

/**
 * Created by XINDZ on 2017/4/24.
 * 功能:全屏视频播放
 */

public class JCVDHActivity extends BaseActivity {
    String url1 = "http://video.sinosns.cn/fmmgc/shuishangfeixing8.mp4";
    private programInfoVo infoVo;
    String title = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jcvd_h);
        Intent get = getIntent();
        infoVo = (programInfoVo) get.getSerializableExtra(programInfoVo.class.getName());
        if (infoVo == null)
            return;
        url = infoVo.getVideo_url();
        String id = infoVo.getId();
        if (id != null && !id.equals("")) {
            RemoteImpl.getInstance().getNewslookNum(this, id, 2).execute(new ResultCallback(this));
        }
        if (infoVo.getName() != null) {
            title = infoVo.getName();
        }
        JCVideoPlayerStandard.startFullscreen(this, JCVideoPlayerStandard.class, url, title);
        JCVideoPlayerStandard.setmOnOutFullScreenListener(new JCVideoPlayer.OnOutFullScreenListener() {
            @Override
            public void onOutFull() {
                finish();
            }
        });
    }

    //JCVD 视频播放
    @Override
    protected void onPause() {
        super.onPause();
        JCVideoPlayer.releaseAllVideos();
    }

    @Override
    public void onBackPressed() {
        if (JCVideoPlayer.backPress()) {
            finish();
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        JCVideoPlayer.releaseAllVideos();
    }
}
